$(function() {
    $("#btn").click(function() {
        var options = {
            url: "http://127.0.0.1:8888/users/register",
            type: "POST",
            dataType: "json",
            data: {
                username: username.value,
                password: password.value,
                rpassword: rpassword.value,
                nickname: nickname.value
            }

        }

        $.ajax(options)
            .done(function(res) {
                render(res);
            })

        function render(res) {
            // console.log(res);
            if (res.code === 1) {
                alert("页面注册成功，马上为您跳转到登录页面");
                setTimeout(function() {
                    location.href = "./login.html";
                }, 2000)
            } else {
                alert(res.message)
            }
        }
    })
})